<?php

include 'Refactoring_Youtube.php';
include 'Refactoring_Flash.php';
include 'Refactoring_Old_Tags.php';
include 'Refactoring_Tag_HTML.php';
include 'Refactoring_Div_New_Tag.php';
include 'Refactoring_Add_Alt_Figure.php';
include 'Refactoring_Add_Tittle.php';
include 'Refactoring_Audio_Tag.php';
include 'Refactoring_Tag_Meta.php';
include 'Refactoring_Tags_Link_Script.php';
include 'Refactoring_Old_Tags_Div.php';
include 'Refactoring_Old_Tags_CSS.php';
include 'Refactoring_Old_Att_Remove.php';
include 'Refactoring_Old_Att_CSS.php';
include 'Refactoring_Table_Layout_Div.php';
include 'Refactoring_Table_Table_Div.php';
include 'Refactoring_Form_Table_Div.php';
include 'Refactoring_Form_Unlabeled.php';

/*
 * Terminar o esquema dos títulos, funcionando para lista, mas quando é somente um obj não foi implementado.
 */

class Class_Web_Refatoring_HTML {

   public $dom;
   public $url;
   public $result;
   public $vhtml;

   /*
    * CONTRUTOR INICIALIZA DOM / CARREGA O HTML / INICIALIZA VARIÁVEL RESUL / INICIALIZA O PROCESSO DE REFATORAÇÃO
    * @param string $url a ser analisada
    */

   public function __construct($url, $vhtml) {
//      $this->url = "../../" . $url;
      $this->url = $url;
      $this->dom = new domDocument;
      $this->dom->loadHTMLFile($url);
      $this->dom->preserveWhiteSpace = false;
      $this->result = "";
      $this->vhtml = $vhtml;
   }

   /*
    * Inicializa a refatoracao
    */

   public function start() {
      if ($this->vhtml == 5) {
         $this->result .= Refactoring_Youtube::start($this->dom);
         $this->result .= Refactoring_Flash::start($this->dom);
         $this->result .= Refactoring_Div_New_Tag::start($this->dom);
         $this->result .= Refactoring_Old_Tags::start($this->dom);
         $this->result .= Refactoring_Tag_HTML::start($this->dom);
         $this->result .= Refactoring_Add_Alt_Figure::start($this->dom);
         $this->result .= Refactoring_Add_Tittle::start($this->dom);
         $this->result .= Refactoring_Audio_Tag::start($this->dom);
         $this->result .= Refactoring_Tag_Meta::start($this->dom);
         $this->result .= Refactoring_Tags_Link_Script::start($this->dom);
         $this->result .= Refactoring_Old_Tags_Div::start($this->dom);
         $this->result .= Refactoring_Old_Tags_CSS::start($this->dom);
         $this->result .= Refactoring_Old_Att_Remove::start($this->dom);
         $this->result .= Refactoring_Old_Att_CSS::start($this->dom);
         $this->result .= Refactoring_Table_Layout_Div::start($this->dom);
         $this->result .= Refactoring_Table_Table_Div::start($this->dom);
         $this->result .= Refactoring_Form_Table_Div::start($this->dom);
         $this->result .= Refactoring_Form_Unlabeled::start($this->dom);
      } else {
         $this->result = "<h3 class='text-danger'>Não implementado</h3>";
      }
   }

}

?>
